﻿#include"state.h"
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int main(){
	clock_t b;
	long i, j, maxLength, testTime, time, a, c;
	SortElem *s, *s1;

	printf("Input Array Size:");
	scanf("%ld",&maxLength);
	s = (SortElem *)malloc(maxLength * sizeof(SortElem));
	s1 = (SortElem *)malloc(maxLength * sizeof(SortElem));
	printf("Input Time You Want to Test:");
	scanf("%ld",&testTime);

	printf("Group\tSortMethod\t\tTime\tMoveTimes\tCompareTimes\n");
	for(j = 0; j<testTime; j++){
		creatRand(s1, maxLength, j);

		setSame(s, s1, maxLength);
		time = clock();
		quickSort(s, maxLength, &a, &c);
		time = clock() - time;
		printf("%ld\tQuickSort\t\t%ld\t%ld\t\t%ld\n", j, time, c, a);

		setSame(s, s1, maxLength);
		time = clock();
		heapSort(s, maxLength, &a, &c);
		time = clock() - time;
		printf("%ld\tHeap\t\t\t%ld\t%ld\t\t%ld\n", j, time, c, a);

		setSame(s, s1, maxLength);
		time = clock();
		dirInsertSort(s, maxLength, &a, &c);
		time = clock() - time;
		printf("%ld\tStraightInsertion\t%ld\t%ld\t%ld\n", j, time, c, a);

		setSame(s, s1, maxLength);
		time = clock();
		dirInsertSort2(s, maxLength, &a, &c);
		time = clock() - time;
		printf("%ld\tBinaryInsertion\t\t%ld\t%ld\t%ld\n", j, time, c, a);

		setSame(s, s1, maxLength);
		time = clock();
		eaSelectSort(s, maxLength, &a, &c);
		time = clock() - time;
		printf("%ld\tSimpleSelection\t\t%ld\t%ld\t%ld\n", j, time, c, a);
		
		setSame(s, s1, maxLength);
		time = clock();
		eaSelectSort2(s, maxLength, &a, &c);
		time = clock() - time;
		printf("%ld\tImprovementSelection\t%ld\t%ld\t\t%ld\n", j, time, c, a);
		
		setSame(s, s1, maxLength);
		time = clock();
		bubbleSort(s, maxLength, &a, &c);
		time = clock() - time;
		printf("%ld\tBubble\t\t\t%ld\t%ld\t%ld\n", j, time, c, a);

		printf("--------------------------------------------------------------------------\n");
	}
}
